import enum

from pydantic import BaseModel


class Power(enum.Enum):
    """用户权限"""
    level = 1
    secondary = 2
    three_level = 3


class UserBase(BaseModel):
    """用户的基本模型"""
    account: str
    name: str


class UserCreate(UserBase):
    """
    创建用户的数据模型
    """
    password: str


class SuperUserCreate(UserCreate):
    """创建超级用户"""
    power: Power | None = Power.level


class User(UserBase):
    """
    用户数据模型
    """
    id: int
    is_active: bool

    class Config:
        from_attributes = True


class UserInDB(User):
    """
    数据库读取的用户模型
    """
    hashed_password: str
    power: Power


class UserAndToken(BaseModel):
    """用户信息与Token的数据模型"""
    userInfo: User
    token: str


class TokenData(BaseModel):
    """token中sub所包含的内容"""
    account: str
